<html>
<title>key-events</title>

<head>
    <script src="./js/vue.js"></script>
    <script>
        window.onload = function () {
            let app = new Vue({
                el: '.container',
                data: {
                },
                methods: {
                    print1: function (e) {
                            console.log("按了回车")
                    },
                    print3: function (e) {
                        if(e.keyCode===13){
                            console.log("按了回车")
                        }
                    }
                }
            })
        }

    </script>
</head>

<body>
    <div class="container">
        <!-- 原生方法判断按键是否是回车键 -->
        <input type="text" @keydown="print3($event)">
        <!-- 简单方法判断按键是否是回车键 -->
        <input type="text" @keydown.13="print1($event)">
        <input type="text" @keydown.enter="print1($event)">
    </div>
</body>

</html>